package com.zhdj.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

import com.zhdj.entity.MasterEntity;
import com.zhdj.service.MasterService;

@Controller
@RequestMapping("master.do")
public class MasterControl {
@Autowired
private MasterService mserv;
		
		@RequestMapping(params = "method=find")
		@ResponseBody
		public int find(String mname){
		int t = this.mserv.find(mname);
		return t;
}
		
		
		@RequestMapping(params = "method=login")
		@ResponseBody
		public int login(String mname,String mpsw,HttpSession session){
			int m=this.mserv.find(mname);
			if(m==0){
				//�˺Ų�����
				return 1;
				
			}else{
				MasterEntity t =this.mserv.login(mname, mpsw);
				if(t==null){
					//�������
					return 2;
					
				}else{
					session.setAttribute("master", t);

			
				
				}
			}
			return 0;
			
			
		}
	}

